<?php
class SleekCMS_AdminNavigationModule extends Module {
	public function run () {
		if (isset($_POST['add_content_type'])) {
			ContentTypesModel::insert(array('title' => $_POST['title']));
			redirect('?added_content_type');
		}

		$rows = ContentTypesModel::get(array('sort' => 'title'));

		if ($rows) {
			foreach ($rows as $k => $row) {
				$rows[$k] = $rows[$k]->asArray();

				$rows[$k]['url'] = url('AdminContents', array('content_types_id' => $rows[$k]['content_types_id']));
			}

			$this->setData('content_types', SleekPHP::router()->setSelectedLink($rows));
		}
	}
}
